package com.studentstreet.component;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.studentstreet.R;

public class StarLayout extends LinearLayout {

	TextView starCount1 = null;
	TextView starCount2 = null;
	TextView starCount3 = null;
	TextView starCount4 = null;
	TextView starCount5 = null;

	TextView lookComment = null;
	TextView addComment = null;

	OnLayoutClickListener listener;

	public interface OnLayoutClickListener {
		void onLookComment();

		void onAddComment();
	}

	public StarLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		starCount1 = (TextView) findViewById(R.id.star_count1);
		starCount2 = (TextView) findViewById(R.id.star_count2);
		starCount3 = (TextView) findViewById(R.id.star_count3);
		starCount4 = (TextView) findViewById(R.id.star_count4);
		starCount5 = (TextView) findViewById(R.id.star_count5);

		lookComment = (TextView) findViewById(R.id.look_comment_tv);
		addComment = (TextView) findViewById(R.id.add_comment_tv);
	}

	public void setComment(int count1, int count2, int count3, int count4,
			int count5) {
		starCount1.setText(getResources().getString(R.string.comment_count,
				count1));
		starCount2.setText(getResources().getString(R.string.comment_count,
				count2));
		starCount3.setText(getResources().getString(R.string.comment_count,
				count3));
		starCount4.setText(getResources().getString(R.string.comment_count,
				count4));
		starCount5.setText(getResources().getString(R.string.comment_count,
				count5));
	}

	public void setOnCommnetLayoutClickListener(
			OnLayoutClickListener layoutListener) {
		this.listener = layoutListener;
		lookComment.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				listener.onLookComment();
			}
		});
		addComment.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				listener.onAddComment();
			}
		});

	}
}
